<template>
	<view class="ewm-page">
		<view class="code-img">
			<ikun-qrcode width="400" height="400" unit="rpx" color="#000000" :data="binary"></ikun-qrcode>
		</view>
	</view>
</template>

<script>

export default {
	data() {
		return {
			brightness: null,
			userinfo: JSON.parse(uni.getStorageSync('userinfo')),
			str: '',
			binary: '',
		};
	},
	onShow() {

	},
	onLoad(option) {
		if (option.str) {
			this.str = JSON.parse(option.str)
			this.generateQRCode()
		}
	},
	methods: {
		async generateQRCode() {
			try {
				const {
					ORMTB444CA00: pdsj,
					ORMTB444CA01: cj,
					ORMTB444CA02: kh,
					ORMTB444CA03: ch,
					ORMTB444CA04: pdwl,
					ORMTB444CA05: jswl,
					ORMTB444CA07: mzsj,
					ORMTB444CA08: lsh,
					ORMTB444CA09: pzsj,
					ORMTB444CA12: jz,
					ORMTB444CA14: mz,
					ORMTB444ID: id,
					pz
				} = this.str

				this.binary = `cj=${cj},kh=${kh},ch=${ch},pdwl=${pdwl},jswl=${jswl},lsh=${lsh},pzsj=${pzsj},pz=${pz},jz=${jz},mz=${mz},id=${id},pdsj=${pdsj},mzsj=${mzsj}`
				// this.binary = `http://baidu.com`
				console.log(this.binary, 'this.str');
			} catch (err) {
				console.error(err);
			}
		},
	},
	mounted() {
		uni.getScreenBrightness({ // 获取屏幕亮度
			success: res => {
				if (res.value !== 1) {
					this.brightness = res.value // 屏幕亮度值，范围 0~1，0 最暗，1 最亮
					uni.setScreenBrightness({ // 设置屏幕亮度
						value: 1 // 屏幕亮度值，范围 0~1，0 最暗，1 最亮
					})
				}
			}
		})
	},
	beforeDestroy() {
		if (this.brightness != null) {
			uni.setScreenBrightness({ // 设置屏幕亮度到进入时的亮度
				value: this.brightness
			})
		}
	},
}
</script>

<style lang="scss" scoped>
.ewm-page {
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--window-top));
	width: 100%;
	background-color: #E3E3E3;
}

.code-img {
	width: 400rpx;
	height: 400rpx;
	margin: 150rpx auto 0;
}

.ewm-main {
	background-color: #ffffff;
	height: calc(100vh - var(--window-top));
}

.slot-wrap {
	display: flex;
	align-items: center;
	justify-content: space-between;
	/* 如果您想让slot内容占满整个导航栏的宽度 */
	flex: 1;
	/* 如果您想让slot内容与导航栏左右有空隙 */
	padding: 0 30rpx;
}

.ERcode-orderinfo {
	font-size: 36rpx;
	color: #333;
	margin-bottom: 65rpx;
	padding: 0 28rpx;
}

.ERcode-orderinfo>view {
	// height: 44rpx;
	line-height: 44rpx;
	overflow: hidden;
}

.ERcode-orderinfo-view {
	border-bottom: 2rpx solid #e3e3e3;
	padding-bottom: 20rpx;
}

.ERcode-orderinfo-view>text:first-child {
	font-size: 44rpx;
	font-weight: 600;
	width: 255rpx !important;
}

.ERcode-orderinfo>view+view {
	margin-top: 15rpx;
}

.ERcode-orderinfo text {
	display: inline-block;
	font-size: 36rpx;
	width: 190rpx;
	text-align: right;
	margin-right: 21rpx;
	color: #666;
}

.zanWSJ {
	padding-top: 200rpx;
}

.zanWSJ>image {
	display: block;
	margin: 0 auto;
	height: 360rpx;
	width: 43%;
}

.qh-dd-an {
	background: #ffffff;
	padding-right: 20rpx;
	padding-top: 20rpx;
	font-size: 30rpx;
	display: flex;
	justify-content: flex-end;
}
</style>